home *** CD-ROM | disk | FTP | other *** search
- #include "PostPre.h"
- #include "Global.h"
-
- struct BitMap *tmpbitmap = NULL;
-
- BOOL createactivation(void)
- {
- int i, depth;
-
- parm.page.depth = Options.PostOpts.depth;
- parm.page.xsize = Options.PostOpts.width;
- parm.page.ysize = bandrendering ? Options.PostOpts.bandsize : Options.PostOpts.height;
- parm.page.ybase = 0;
- parm.page.yheight = Options.PostOpts.height;
- parm.page.xoff = Options.PostOpts.xoff;
- parm.page.yoff = Options.PostOpts.yoff;
- parm.page.xden = Options.PostOpts.xdpi;
- parm.page.yden = Options.PostOpts.ydpi;
- parm.page.ydir = -1;
-
- parm.memvlen = Options.PostOpts.vm;
- parm.memflen = Options.PostOpts.fonts;
- parm.memllen = Options.PostOpts.paths;
- parm.memhlen = Options.PostOpts.htone;
-
- parm.page.xbytes = (Options.PostOpts.width + 15) >> 3 & 0xfffffffe;
- parm.page.len = parm.page.xbytes * parm.page.ysize;
-
- /* Allocate the page buffer. It must be in chip memory if we are
- * outputting to a screen */
-
- if(Options.graphiccard && parm.page.depth > 1) depth = parm.page.depth+1;
- else depth = parm.page.depth;
- InitBitMap(&bitmap, depth, parm.page.xsize, parm.page.ysize);
- for (i = 0; i < 8; i++)
- {
- bitmap.Planes[i] = NULL;
- }
- if(argwindow)
- {
- if(os_3)
- {
- tmpbitmap = AllocBitMap(parm.page.xsize, parm.page.ysize,
- depth, BMF_CLEAR, NULL);
- if(tmpbitmap == NULL)
- {
- okmsg("can't get page buffer");
- return(FALSE);
- }
- for (i = 0; i < parm.page.depth; i++)
- {
- parm.page.buf[i] = tmpbitmap->Planes[i];
- }
- memcpy((char *) &bitmap, (char *) tmpbitmap, sizeof(struct BitMap));
- }
- else
- {
- for (i = 0; i < depth; i++)
- {
- if((bitmap.Planes[i] = (PLANEPTR)
- AllocRaster(parm.page.xsize, parm.page.ysize)) == NULL)
- {
- okmsg("can't get page buffer");
- return(FALSE);
- }
- parm.page.buf[i] = bitmap.Planes[i];
- BltClear(bitmap.Planes[i], parm.page.len, 0x0);
- }
- }
- if(parm.page.depth > 1)
- {
- /* A Plane-Pointer with value -1 will be interpreted like a Plane with *
- * all pixels set. So we don't need the memory for the Plane :-). *
- * But some graphiccards don't work correctly this way, so we have to *
- * allocate a fake bitmap and set all pixels in it */
-
- if(Options.graphiccard)
- {
- BltClear(bitmap.Planes[bitmap.Depth - 1], parm.page.len, 0xFFFF0005);
- }
- else
- {
- bitmap.Depth++;
- bitmap.Planes[bitmap.Depth-1] = (char *) -1;
- }
- }
- }
- else
- {
- for (i = 0; i < parm.page.depth; i++)
- {
- if((bitmap.Planes[i] = (PLANEPTR)
- AllocMem(parm.page.len, MEMF_PUBLIC|MEMF_CLEAR)) == NULL)
- {
- okmsg("can't get page buffer");
- return(FALSE);
- }
- parm.page.buf[i] = bitmap.Planes[i];
- }
- output_bitmap = bitmap;
- }
- parm.flushfunc = (APTR) flushpage;
- parm.copyfunc = (APTR) copypage;
-
- if (confh)
- {
- parm.infh = confh;
- parm.outfh = confh;
- parm.errfh = confh;
- }
- else
- {
- parm.infh = Input();
- parm.outfh = Output();
- parm.errfh = errfh;
- }
-
-
- arec = PScreateact(&parm);
- if (arec == 0)
- {
- okmsg("can't get memory");
- return(FALSE);
- }
- else if ((unsigned) arec <= errmax)
- {
- okmsg("error during initiation in PScreateact");
- arec = NULL;
- return(FALSE);
- }
- return(TRUE);
- }
-
- /* Interpret the argument files */
-
- void runstartupfiles(void)
- {
- struct Node *node;
- char directory[256];
-
- for(node = Options.startuplist.lh_Head; node->ln_Succ; node = node->ln_Succ)
- {
- getpath(directory, node->ln_Name);
- changedir(directory);
- sendmenu(PSACTSTARTUP, 0, 0, 0, node->ln_Name, directory);
- }
- }
-
- BOOL openconwin(void)
- {
- char fname[256];
-
- if(Options.Screen.custscreen)
- {
- sprintf((char *) fname, "CON:0/0/640/100/PostIO.%d/AUTO/SCREEN%s%d", post_count, PSNAME, post_count);
- }
- else
- {
- sprintf((char *) fname, "CON:0/0/640/100/PostIO.%d/AUTO/SCREEN%s", post_count, pubscreenname);
- }
- confh = Open((char *) fname, MODE_NEWFILE);
- if (confh == NULL)
- {
- okmsg("can't open console handler");
- return(FALSE);
- }
- return(TRUE);
- }
-
- void deleteactivation(void)
- {
- int i, depth;
- char dummy[3];
-
- if(arec)
- {
- PSdeleteact(arec);
- arec = NULL;
- }
- if (confh)
- {
- if(argcon && !argwindow && argverbose)
- {
- FPrintf(confh, "finished!\nPress return to quit!\n");
- Read(confh, dummy, 1);
- }
- Close(confh);
- confh = NULL;
- }
- if(argwindow)
- {
- if(Options.graphiccard && parm.page.depth > 1) depth = parm.page.depth+1;
- else depth = parm.page.depth;
- if(os_3 && tmpbitmap)
- {
- FreeBitMap(tmpbitmap);
- tmpbitmap = NULL;
- }
- else
- {
- for (i = 0; i < depth; i++)
- {
- if (bitmap.Planes[i])
- {
- FreeRaster(bitmap.Planes[i], parm.page.xsize, parm.page.ysize);
- parm.page.buf[i] = NULL;
- bitmap.Planes[i] = NULL;
- }
- }
- }
- }
- else
- {
- for (i = 0; i < parm.page.depth; i++)
- {
- if (parm.page.buf[i])
- {
- FreeMem(parm.page.buf[i], parm.page.len);
- parm.page.buf[i] = NULL;
- }
- }
- }
- for (i = 0; i < 8; i++)
- {
- if (parm.page.buf[i])
- {
- parm.page.buf[i] = NULL;
- bitmap.Planes[i] = NULL;
- }
- }
- }
-